package com.wc.codeforces.数学.约数.Problem_about_GCD;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/1/4 16:18
 * @description
 * https://codeforces.com/contest/2043/problem/D
 */
public class Main {
    /**
     * 思路：
     * 求左边界和有右边界
     * L = (l + g - 1) / g * g
     * R = r / g * g
     * 边界的间隔
     * sub = (R - L) / g
     * 间隔边界最小的就是 0
     * bound = 0 ~ sub, 左边界是 a, 距离右边界是 b
     * L + a * g, R - b * g; , a + b = bound
     * 找到最小的就完成了
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static long l, r, g;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            l = sc.nextLong();
            r = sc.nextLong();
            g = sc.nextLong();
            long L = (l + g - 1) / g * g, R = r / g * g;
            long sub = (R - L) / g;
            long x = -1, y = -1;
            // sub 表示与左右边界的间隔, 间隔是 i, 一边是 j, 另外一遍就是 i - j, 因为要 x 最小, 所以只能让 L + j * g
            for (int i = 0; i <= sub; i++) {
                for (int j = 0; j <= i; j++) {
                    if (gcd(L + j * g, R - (i - j) * g) == g) {
                        x = L + j * g;
                        y = R - (i - j) * g;
                        break;
                    }
                }
                if (x != -1) break;
            }


            out.println(x + " " + y);
        }
        out.flush();
    }

    static long gcd(long a, long b) {
        return b > 0 ? gcd(b, a % b) : a;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

